package project.controllers;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;

import api.messages.Messager;



public class DateFormatter {
	private static final Logger log = Logger.getLogger(DateFormatter.class);
	private ConsoleScanner console_scanner;
	
	
	public DateFormatter(){
		console_scanner=ConsoleScanner.getInstance();
	}
	
	public Date formatDate(){
		String consoleLine=console_scanner.getData();
		SimpleDateFormat formatter = new SimpleDateFormat(Messager.DATE_FORMAT);
		Date date=new Date();
		
		try{
			 date = formatter.parse(consoleLine);
			 
			
			
		}catch(ParseException pe){
			log.error(Messager.WRONG_DATE_FORMAT);
			Printer.printMessage(Messager.WRONG_DATE_FORMAT);
		}
		
		return date;
	}
	
	
	
	public  String getString(){
		String consoleLine=console_scanner.getData();
		return consoleLine;
	}
	
	

	
}
